<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>datetimeformat_test.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_i18n_datetimeformat_test.js.html">datetimeformat_test.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2008 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>goog.provide(&#39;goog.i18n.DateTimeFormatTest&#39;);
<a name="line16"></a>goog.setTestOnly(&#39;goog.i18n.DateTimeFormatTest&#39;);
<a name="line17"></a>
<a name="line18"></a>goog.require(&#39;goog.date.Date&#39;);
<a name="line19"></a>goog.require(&#39;goog.date.DateTime&#39;);
<a name="line20"></a>goog.require(&#39;goog.i18n.DateTimeFormat&#39;);
<a name="line21"></a>goog.require(&#39;goog.i18n.DateTimePatterns&#39;);
<a name="line22"></a>goog.require(&#39;goog.i18n.DateTimePatterns_de&#39;);
<a name="line23"></a>goog.require(&#39;goog.i18n.DateTimePatterns_en&#39;);
<a name="line24"></a>goog.require(&#39;goog.i18n.DateTimePatterns_fa&#39;);
<a name="line25"></a>goog.require(&#39;goog.i18n.DateTimePatterns_fr&#39;);
<a name="line26"></a>goog.require(&#39;goog.i18n.DateTimePatterns_ja&#39;);
<a name="line27"></a>goog.require(&#39;goog.i18n.DateTimePatterns_sv&#39;);
<a name="line28"></a>goog.require(&#39;goog.i18n.DateTimeSymbols&#39;);
<a name="line29"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_ar_AE&#39;);
<a name="line30"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_ar_SA&#39;);
<a name="line31"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_bn_BD&#39;);
<a name="line32"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_de&#39;);
<a name="line33"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_en&#39;);
<a name="line34"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_en_GB&#39;);
<a name="line35"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_en_IE&#39;);
<a name="line36"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_en_IN&#39;);
<a name="line37"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_en_US&#39;);
<a name="line38"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_fa&#39;);
<a name="line39"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_fr&#39;);
<a name="line40"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_fr_DJ&#39;);
<a name="line41"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_he_IL&#39;);
<a name="line42"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_ja&#39;);
<a name="line43"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_ro_RO&#39;);
<a name="line44"></a>goog.require(&#39;goog.i18n.DateTimeSymbols_sv&#39;);
<a name="line45"></a>goog.require(&#39;goog.i18n.TimeZone&#39;);
<a name="line46"></a>goog.require(&#39;goog.testing.jsunit&#39;);
<a name="line47"></a>
<a name="line48"></a>// Initial values
<a name="line49"></a>goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_en;
<a name="line50"></a>goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_en;
<a name="line51"></a>
<a name="line52"></a>function tearDown() {
<a name="line53"></a>  // We always revert to a known state
<a name="line54"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_en;
<a name="line55"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_en;
<a name="line56"></a>}
<a name="line57"></a>
<a name="line58"></a>// Helpers to make tests work regardless of the timeZone we&#39;re in.
<a name="line59"></a>function timezoneString(date) {
<a name="line60"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(date.getTimezoneOffset());
<a name="line61"></a>  return timeZone.getShortName(date);
<a name="line62"></a>}
<a name="line63"></a>
<a name="line64"></a>function timezoneId(date) {
<a name="line65"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(
<a name="line66"></a>      date.getTimezoneOffset());
<a name="line67"></a>  return timeZone.getTimeZoneId(date);
<a name="line68"></a>}
<a name="line69"></a>
<a name="line70"></a>function timezoneStringRFC(date) {
<a name="line71"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(date.getTimezoneOffset());
<a name="line72"></a>  return timeZone.getRFCTimeZoneString(date);
<a name="line73"></a>}
<a name="line74"></a>
<a name="line75"></a>// Where could such data be found
<a name="line76"></a>// In js_i18n_data in http://go/i18n_dir, we have a bunch of files with names
<a name="line77"></a>// like TimeZoneConstant__&lt;locale&gt;.js
<a name="line78"></a>// We strongly discourage you to use them directly as those data can make
<a name="line79"></a>// your client code bloated. You should try to provide this data from server
<a name="line80"></a>// in a selective manner. In typical scenario, user&#39;s time zone is retrieved
<a name="line81"></a>// and only data for that time zone should be provided.
<a name="line82"></a>var americaLosAngelesData = {
<a name="line83"></a>  &#39;transitions&#39;: [
<a name="line84"></a>    2770, 60, 7137, 0, 11506, 60, 16041, 0, 20410, 60, 24777, 0, 29146, 60,
<a name="line85"></a>    33513, 0, 35194, 60, 42249, 0, 45106, 60, 50985, 0, 55354, 60, 59889, 0,
<a name="line86"></a>    64090, 60, 68625, 0, 72994, 60, 77361, 0, 81730, 60, 86097, 0, 90466, 60,
<a name="line87"></a>    94833, 0, 99202, 60, 103569, 0, 107938, 60, 112473, 0, 116674, 60, 121209,
<a name="line88"></a>    0, 125578, 60, 129945, 0, 134314, 60, 138681, 0, 143050, 60, 147417, 0,
<a name="line89"></a>    151282, 60, 156153, 0, 160018, 60, 165057, 0, 168754, 60, 173793, 0,
<a name="line90"></a>    177490, 60, 182529, 0, 186394, 60, 191265, 0, 195130, 60, 200001, 0,
<a name="line91"></a>    203866, 60, 208905, 0, 212602, 60, 217641, 0, 221338, 60, 226377, 0,
<a name="line92"></a>    230242, 60, 235113, 0, 238978, 60, 243849, 0, 247714, 60, 252585, 0,
<a name="line93"></a>    256450, 60, 261489, 0, 265186, 60, 270225, 0, 273922, 60, 278961, 0,
<a name="line94"></a>    282826, 60, 287697, 0, 291562, 60, 296433, 0, 300298, 60, 305337, 0,
<a name="line95"></a>    309034, 60, 314073, 0, 317770, 60, 322809, 0, 326002, 60, 331713, 0,
<a name="line96"></a>    334738, 60, 340449, 0, 343474, 60, 349185, 0, 352378, 60, 358089, 0,
<a name="line97"></a>    361114, 60, 366825, 0, 369850, 60, 375561, 0, 378586, 60, 384297, 0,
<a name="line98"></a>    387322, 60, 393033, 0, 396058, 60, 401769, 0, 404962, 60, 410673, 0,
<a name="line99"></a>    413698, 60, 419409, 0, 422434, 60, 428145, 0, 431170, 60, 436881, 0,
<a name="line100"></a>    439906, 60, 445617, 0, 448810, 60, 454521, 0, 457546, 60, 463257, 0,
<a name="line101"></a>    466282, 60, 471993, 0, 475018, 60, 480729, 0, 483754, 60, 489465, 0,
<a name="line102"></a>    492490, 60, 498201, 0, 501394, 60, 507105, 0, 510130, 60, 515841, 0,
<a name="line103"></a>    518866, 60, 524577, 0, 527602, 60, 533313, 0, 536338, 60, 542049, 0,
<a name="line104"></a>    545242, 60, 550953, 0, 553978, 60, 559689, 0, 562714, 60, 568425, 0,
<a name="line105"></a>    571450, 60, 577161, 0, 580186, 60, 585897, 0, 588922, 60, 594633, 0
<a name="line106"></a>  ],
<a name="line107"></a>  &#39;names&#39;: [&#39;PST&#39;, &#39;Pacific Standard Time&#39;, &#39;PDT&#39;, &#39;Pacific Daylight Time&#39;],
<a name="line108"></a>  &#39;id&#39;: &#39;America/Los_Angeles&#39;,
<a name="line109"></a>  &#39;std_offset&#39;: -480
<a name="line110"></a>};
<a name="line111"></a>
<a name="line112"></a>var europeBerlinData = {
<a name="line113"></a>  &#39;transitions&#39;: [
<a name="line114"></a>    89953, 60, 94153, 0, 98521, 60, 102889, 0, 107257, 60, 111625, 0,
<a name="line115"></a>    115993, 60, 120361, 0, 124729, 60, 129265, 0, 133633, 60, 138001, 0,
<a name="line116"></a>    142369, 60, 146737, 0, 151105, 60, 155473, 0, 159841, 60, 164209, 0,
<a name="line117"></a>    168577, 60, 172945, 0, 177313, 60, 181849, 0, 186217, 60, 190585, 0,
<a name="line118"></a>    194953, 60, 199321, 0, 203689, 60, 208057, 0, 212425, 60, 216793, 0,
<a name="line119"></a>    221161, 60, 225529, 0, 230065, 60, 235105, 0, 238801, 60, 243841, 0,
<a name="line120"></a>    247537, 60, 252577, 0, 256273, 60, 261481, 0, 265009, 60, 270217, 0,
<a name="line121"></a>    273745, 60, 278953, 0, 282649, 60, 287689, 0, 291385, 60, 296425, 0,
<a name="line122"></a>    300121, 60, 305329, 0, 308857, 60, 314065, 0, 317593, 60, 322801, 0,
<a name="line123"></a>    326329, 60, 331537, 0, 335233, 60, 340273, 0, 343969, 60, 349009, 0,
<a name="line124"></a>    352705, 60, 357913, 0, 361441, 60, 366649, 0, 370177, 60, 375385, 0,
<a name="line125"></a>    379081, 60, 384121, 0, 387817, 60, 392857, 0, 396553, 60, 401593, 0,
<a name="line126"></a>    405289, 60, 410497, 0, 414025, 60, 419233, 0, 422761, 60, 427969, 0,
<a name="line127"></a>    431665, 60, 436705, 0, 440401, 60, 445441, 0, 449137, 60, 454345, 0,
<a name="line128"></a>    457873, 60, 463081, 0, 466609, 60, 471817, 0, 475513, 60, 480553, 0,
<a name="line129"></a>    484249, 60, 489289, 0, 492985, 60, 498025, 0, 501721, 60, 506929, 0,
<a name="line130"></a>    510457, 60, 515665, 0, 519193, 60, 524401, 0, 528097, 60, 533137, 0,
<a name="line131"></a>    536833, 60, 541873, 0, 545569, 60, 550777, 0, 554305, 60, 559513, 0,
<a name="line132"></a>    563041, 60, 568249, 0, 571777, 60, 576985, 0, 580681, 60, 585721, 0,
<a name="line133"></a>    589417, 60, 594457, 0],
<a name="line134"></a>  &#39;names&#39;: [&#39;MEZ&#39;, &#39;Mitteleurop\u00e4ische Zeit&#39;,
<a name="line135"></a>            &#39;MESZ&#39;, &#39;Mitteleurop\u00e4ische Sommerzeit&#39;],
<a name="line136"></a>  &#39;id&#39;: &#39;Europe/Berlin&#39;,
<a name="line137"></a>  &#39;std_offset&#39;: 60
<a name="line138"></a>};
<a name="line139"></a>
<a name="line140"></a>var date;
<a name="line141"></a>
<a name="line142"></a>function testHHmmss() {
<a name="line143"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line144"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line145"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line146"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;HH:mm:ss&#39;);
<a name="line147"></a>  assertEquals(&#39;13:10:10&#39;, fmt.format(date));
<a name="line148"></a>}
<a name="line149"></a>
<a name="line150"></a>function testhhmmssa() {
<a name="line151"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line152"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line153"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line154"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;h:mm:ss a&#39;);
<a name="line155"></a>  assertEquals(&#39;1:10:10 nachm.&#39;, fmt.format(date));
<a name="line156"></a>}
<a name="line157"></a>
<a name="line158"></a>function testEEEMMMddyy() {
<a name="line159"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line160"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line161"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line162"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;EEE, MMM d, yy&#39;);
<a name="line163"></a>  assertEquals(&#39;Do., Juli 27, 06&#39;, fmt.format(date));
<a name="line164"></a>}
<a name="line165"></a>
<a name="line166"></a>function testEEEEMMMddyy() {
<a name="line167"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line168"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line169"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line170"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;EEEE,MMMM dd, yyyy&#39;);
<a name="line171"></a>  assertEquals(&#39;Donnerstag,Juli 27, 2006&#39;, fmt.format(date));
<a name="line172"></a>}
<a name="line173"></a>
<a name="line174"></a>function testyyyyMMddG() {
<a name="line175"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line176"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line177"></a>  date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10, 250));
<a name="line178"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(420,
<a name="line179"></a>      goog.i18n.DateTimeSymbols_de);
<a name="line180"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;yyyy.MM.dd G \&#39;at\&#39; HH:mm:ss vvvv&#39;);
<a name="line181"></a>  assertEquals(&#39;2006.07.27 n. Chr. at 06:10:10 Etc/GMT+7&#39;,
<a name="line182"></a>               fmt.format(date, timeZone));
<a name="line183"></a>}
<a name="line184"></a>
<a name="line185"></a>function testyyyyyMMMMM() {
<a name="line186"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line187"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line188"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line189"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;yyyyy.MMMMM.dd GGG hh:mm aaa&#39;);
<a name="line190"></a>  assertEquals(&#39;02006.J.27 n. Chr. 01:10 nachm.&#39;, fmt.format(date));
<a name="line191"></a>
<a name="line192"></a>  date = new Date(972, 11, 25, 13, 10, 10, 250);
<a name="line193"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;yyyyy.MMMMM.dd&#39;);
<a name="line194"></a>  assertEquals(&#39;00972.D.25&#39;, fmt.format(date));
<a name="line195"></a>}
<a name="line196"></a>
<a name="line197"></a>function testQQQQyy() {
<a name="line198"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line199"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line200"></a>  date = new Date(2006, 0, 27, 13, 10, 10, 250);
<a name="line201"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;QQQQ yy&#39;);
<a name="line202"></a>  assertEquals(&#39;1. Quartal 06&#39;, fmt.format(date));
<a name="line203"></a>  date = new Date(2006, 1, 27, 13, 10, 10, 250);
<a name="line204"></a>  assertEquals(&#39;1. Quartal 06&#39;, fmt.format(date));
<a name="line205"></a>  date = new Date(2006, 2, 27, 13, 10, 10, 250);
<a name="line206"></a>  assertEquals(&#39;1. Quartal 06&#39;, fmt.format(date));
<a name="line207"></a>  date = new Date(2006, 3, 27, 13, 10, 10, 250);
<a name="line208"></a>  assertEquals(&#39;2. Quartal 06&#39;, fmt.format(date));
<a name="line209"></a>  date = new Date(2006, 4, 27, 13, 10, 10, 250);
<a name="line210"></a>  assertEquals(&#39;2. Quartal 06&#39;, fmt.format(date));
<a name="line211"></a>  date = new Date(2006, 5, 27, 13, 10, 10, 250);
<a name="line212"></a>  assertEquals(&#39;2. Quartal 06&#39;, fmt.format(date));
<a name="line213"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line214"></a>  assertEquals(&#39;3. Quartal 06&#39;, fmt.format(date));
<a name="line215"></a>  date = new Date(2006, 7, 27, 13, 10, 10, 250);
<a name="line216"></a>  assertEquals(&#39;3. Quartal 06&#39;, fmt.format(date));
<a name="line217"></a>  date = new Date(2006, 8, 27, 13, 10, 10, 250);
<a name="line218"></a>  assertEquals(&#39;3. Quartal 06&#39;, fmt.format(date));
<a name="line219"></a>  date = new Date(2006, 9, 27, 13, 10, 10, 250);
<a name="line220"></a>  assertEquals(&#39;4. Quartal 06&#39;, fmt.format(date));
<a name="line221"></a>  date = new Date(2006, 10, 27, 13, 10, 10, 250);
<a name="line222"></a>  assertEquals(&#39;4. Quartal 06&#39;, fmt.format(date));
<a name="line223"></a>  date = new Date(2006, 11, 27, 13, 10, 10, 250);
<a name="line224"></a>  assertEquals(&#39;4. Quartal 06&#39;, fmt.format(date));
<a name="line225"></a>}
<a name="line226"></a>
<a name="line227"></a>function testQQyyyy() {
<a name="line228"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line229"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line230"></a>  date = new Date(2006, 0, 27, 13, 10, 10, 250);
<a name="line231"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;QQ yyyy&#39;);
<a name="line232"></a>  assertEquals(&#39;Q1 2006&#39;, fmt.format(date));
<a name="line233"></a>  date = new Date(2006, 1, 27, 13, 10, 10, 250);
<a name="line234"></a>  assertEquals(&#39;Q1 2006&#39;, fmt.format(date));
<a name="line235"></a>  date = new Date(2006, 2, 27, 13, 10, 10, 250);
<a name="line236"></a>  assertEquals(&#39;Q1 2006&#39;, fmt.format(date));
<a name="line237"></a>  date = new Date(2006, 3, 27, 13, 10, 10, 250);
<a name="line238"></a>  assertEquals(&#39;Q2 2006&#39;, fmt.format(date));
<a name="line239"></a>  date = new Date(2006, 4, 27, 13, 10, 10, 250);
<a name="line240"></a>  assertEquals(&#39;Q2 2006&#39;, fmt.format(date));
<a name="line241"></a>  date = new Date(2006, 5, 27, 13, 10, 10, 250);
<a name="line242"></a>  assertEquals(&#39;Q2 2006&#39;, fmt.format(date));
<a name="line243"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line244"></a>  assertEquals(&#39;Q3 2006&#39;, fmt.format(date));
<a name="line245"></a>  date = new Date(2006, 7, 27, 13, 10, 10, 250);
<a name="line246"></a>  assertEquals(&#39;Q3 2006&#39;, fmt.format(date));
<a name="line247"></a>  date = new Date(2006, 8, 27, 13, 10, 10, 250);
<a name="line248"></a>  assertEquals(&#39;Q3 2006&#39;, fmt.format(date));
<a name="line249"></a>  date = new Date(2006, 9, 27, 13, 10, 10, 250);
<a name="line250"></a>  assertEquals(&#39;Q4 2006&#39;, fmt.format(date));
<a name="line251"></a>  date = new Date(2006, 10, 27, 13, 10, 10, 250);
<a name="line252"></a>  assertEquals(&#39;Q4 2006&#39;, fmt.format(date));
<a name="line253"></a>  date = new Date(2006, 11, 27, 13, 10, 10, 250);
<a name="line254"></a>  assertEquals(&#39;Q4 2006&#39;, fmt.format(date));
<a name="line255"></a>}
<a name="line256"></a>
<a name="line257"></a>function testMMddyyyyHHmmsszzz() {
<a name="line258"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line259"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line260"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line261"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zzz&#39;);
<a name="line262"></a>  assertEquals(&#39;07/27/2006 13:10:10 &#39; + timezoneString(date),
<a name="line263"></a>      fmt.format(date));
<a name="line264"></a>}
<a name="line265"></a>
<a name="line266"></a>function testMMddyyyyHHmmssZ() {
<a name="line267"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line268"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line269"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line270"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss Z&#39;);
<a name="line271"></a>  assertEquals(&#39;07/27/2006 13:10:10 &#39; + timezoneStringRFC(date),
<a name="line272"></a>      fmt.format(date));
<a name="line273"></a>}
<a name="line274"></a>
<a name="line275"></a>function testPatternMonthDayMedium() {
<a name="line276"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line277"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line278"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line279"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line280"></a>      goog.i18n.DateTimePatterns.MONTH_DAY_MEDIUM);
<a name="line281"></a>  assertEquals(&#39;27. Juli&#39;, fmt.format(date));
<a name="line282"></a>}
<a name="line283"></a>
<a name="line284"></a>function testPatternDayOfWeekMonthDayMedium() {
<a name="line285"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line286"></a>
<a name="line287"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line288"></a>      goog.i18n.DateTimePatterns.WEEKDAY_MONTH_DAY_MEDIUM);
<a name="line289"></a>  assertEquals(&#39;Thu, Jul 27&#39;, fmt.format(date));
<a name="line290"></a>
<a name="line291"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line292"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line293"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line294"></a>      goog.i18n.DateTimePatterns.WEEKDAY_MONTH_DAY_MEDIUM);
<a name="line295"></a>  assertEquals(&#39;Do., 27. Juli&#39;, fmt.format(date));
<a name="line296"></a>}
<a name="line297"></a>
<a name="line298"></a>function testPatternDayOfWeekMonthDayYearMedium() {
<a name="line299"></a>  date = new Date(2012, 5, 28, 13, 10, 10, 250);
<a name="line300"></a>
<a name="line301"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line302"></a>      goog.i18n.DateTimePatterns.WEEKDAY_MONTH_DAY_YEAR_MEDIUM);
<a name="line303"></a>  assertEquals(&#39;Thu, Jun 28, 2012&#39;, fmt.format(date));
<a name="line304"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line305"></a>      goog.i18n.DateTimePatterns.MONTH_DAY_YEAR_MEDIUM);
<a name="line306"></a>  assertEquals(&#39;Jun 28, 2012&#39;, fmt.format(date));
<a name="line307"></a>
<a name="line308"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_sv;
<a name="line309"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_sv;
<a name="line310"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line311"></a>      goog.i18n.DateTimePatterns.WEEKDAY_MONTH_DAY_YEAR_MEDIUM);
<a name="line312"></a>  assertEquals(&#39;tors 28 jun 2012&#39;, fmt.format(date));
<a name="line313"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line314"></a>      goog.i18n.DateTimePatterns.MONTH_DAY_YEAR_MEDIUM);
<a name="line315"></a>  assertEquals(&#39;28 jun 2012&#39;, fmt.format(date));
<a name="line316"></a>}
<a name="line317"></a>
<a name="line318"></a>function testQuote() {
<a name="line319"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line320"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line321"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line322"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;HH \&#39;o\&#39;\&#39;clock\&#39;&#39;);
<a name="line323"></a>  assertEquals(&#39;13 o\&#39;clock&#39;, fmt.format(date));
<a name="line324"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;HH \&#39;oclock\&#39;&#39;);
<a name="line325"></a>  assertEquals(&#39;13 oclock&#39;, fmt.format(date));
<a name="line326"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;HH \&#39;\&#39;&#39;);
<a name="line327"></a>  assertEquals(&#39;13 \&#39;&#39;, fmt.format(date));
<a name="line328"></a>}
<a name="line329"></a>
<a name="line330"></a>function testFractionalSeconds() {
<a name="line331"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line332"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line333"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 256);
<a name="line334"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;s:S&#39;);
<a name="line335"></a>  assertEquals(&#39;10:3&#39;, fmt.format(date));
<a name="line336"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;s:SS&#39;);
<a name="line337"></a>  assertEquals(&#39;10:26&#39;, fmt.format(date));
<a name="line338"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;s:SSS&#39;);
<a name="line339"></a>  assertEquals(&#39;10:256&#39;, fmt.format(date));
<a name="line340"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;s:SSSS&#39;);
<a name="line341"></a>  assertEquals(&#39;10:2560&#39;, fmt.format(date));
<a name="line342"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;s:SSSSS&#39;);
<a name="line343"></a>  assertEquals(&#39;10:25600&#39;, fmt.format(date));
<a name="line344"></a>}
<a name="line345"></a>
<a name="line346"></a>function testPredefinedFormatter() {
<a name="line347"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line348"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line349"></a>  date = new Date(2006, 7, 4, 13, 49, 24, 000);
<a name="line350"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line351"></a>      goog.i18n.DateTimeFormat.Format.FULL_DATE);
<a name="line352"></a>  assertEquals(&#39;Freitag, 4. August 2006&#39;, fmt.format(date));
<a name="line353"></a>  fmt = new goog.i18n.DateTimeFormat(goog.i18n.DateTimeFormat.Format.LONG_DATE);
<a name="line354"></a>  assertEquals(&#39;4. August 2006&#39;, fmt.format(date));
<a name="line355"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line356"></a>      goog.i18n.DateTimeFormat.Format.MEDIUM_DATE);
<a name="line357"></a>  assertEquals(&#39;04.08.2006&#39;, fmt.format(date));
<a name="line358"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line359"></a>      goog.i18n.DateTimeFormat.Format.SHORT_DATE);
<a name="line360"></a>  assertEquals(&#39;04.08.06&#39;, fmt.format(date));
<a name="line361"></a>  fmt = new goog.i18n.DateTimeFormat(goog.i18n.DateTimeFormat.Format.FULL_TIME);
<a name="line362"></a>  assertEquals(&#39;13:49:24 &#39; + timezoneString(date), fmt.format(date));
<a name="line363"></a>  fmt = new goog.i18n.DateTimeFormat(goog.i18n.DateTimeFormat.Format.LONG_TIME);
<a name="line364"></a>  assertEquals(&#39;13:49:24 &#39; + timezoneString(date), fmt.format(date));
<a name="line365"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line366"></a>      goog.i18n.DateTimeFormat.Format.MEDIUM_TIME);
<a name="line367"></a>  assertEquals(&#39;13:49:24&#39;, fmt.format(date));
<a name="line368"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line369"></a>      goog.i18n.DateTimeFormat.Format.SHORT_TIME);
<a name="line370"></a>  assertEquals(&#39;13:49&#39;, fmt.format(date));
<a name="line371"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line372"></a>      goog.i18n.DateTimeFormat.Format.FULL_DATETIME);
<a name="line373"></a>  assertEquals(&#39;Freitag, 4. August 2006 13:49:24 &#39; + timezoneString(date),
<a name="line374"></a>      fmt.format(date));
<a name="line375"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line376"></a>      goog.i18n.DateTimeFormat.Format.LONG_DATETIME);
<a name="line377"></a>  assertEquals(&#39;4. August 2006 13:49:24 &#39; + timezoneString(date),
<a name="line378"></a>      fmt.format(date));
<a name="line379"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line380"></a>      goog.i18n.DateTimeFormat.Format.MEDIUM_DATETIME);
<a name="line381"></a>  assertEquals(&#39;04.08.2006 13:49:24&#39;, fmt.format(date));
<a name="line382"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line383"></a>      goog.i18n.DateTimeFormat.Format.SHORT_DATETIME);
<a name="line384"></a>  assertEquals(&#39;04.08.06 13:49&#39;, fmt.format(date));
<a name="line385"></a>}
<a name="line386"></a>
<a name="line387"></a>function testMMddyyyyHHmmssZSimpleTimeZone() {
<a name="line388"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line389"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line390"></a>  var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
<a name="line391"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(480);
<a name="line392"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss Z&#39;);
<a name="line393"></a>  assertEquals(&#39;07/27/2006 05:10:10 -0800&#39;, fmt.format(date, timeZone));
<a name="line394"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss ZZ&#39;);
<a name="line395"></a>  assertEquals(&#39;07/27/2006 05:10:10 -0800&#39;, fmt.format(date, timeZone));
<a name="line396"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss ZZZ&#39;);
<a name="line397"></a>  assertEquals(&#39;07/27/2006 05:10:10 -0800&#39;, fmt.format(date, timeZone));
<a name="line398"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss ZZZZ&#39;);
<a name="line399"></a>  assertEquals(&#39;07/27/2006 05:10:10 GMT-08:00&#39;, fmt.format(date, timeZone));
<a name="line400"></a>}
<a name="line401"></a>
<a name="line402"></a>
<a name="line403"></a>function testMMddyyyyHHmmssZCommonTimeZone() {
<a name="line404"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line405"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line406"></a>  var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
<a name="line407"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(americaLosAngelesData);
<a name="line408"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss Z&#39;);
<a name="line409"></a>  assertEquals(&#39;07/27/2006 06:10:10 -0700&#39;, fmt.format(date, timeZone));
<a name="line410"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss ZZ&#39;);
<a name="line411"></a>  assertEquals(&#39;07/27/2006 06:10:10 -0700&#39;, fmt.format(date, timeZone));
<a name="line412"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss ZZZ&#39;);
<a name="line413"></a>  assertEquals(&#39;07/27/2006 06:10:10 -0700&#39;, fmt.format(date, timeZone));
<a name="line414"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss ZZZZ&#39;);
<a name="line415"></a>  assertEquals(&#39;07/27/2006 06:10:10 GMT-07:00&#39;, fmt.format(date, timeZone));
<a name="line416"></a>  date = new Date(Date.UTC(2006, 1, 27, 13, 10, 10));
<a name="line417"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss Z&#39;);
<a name="line418"></a>  assertEquals(&#39;02/27/2006 05:10:10 -0800&#39;, fmt.format(date, timeZone));
<a name="line419"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss ZZ&#39;);
<a name="line420"></a>  assertEquals(&#39;02/27/2006 05:10:10 -0800&#39;, fmt.format(date, timeZone));
<a name="line421"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss ZZZ&#39;);
<a name="line422"></a>  assertEquals(&#39;02/27/2006 05:10:10 -0800&#39;, fmt.format(date, timeZone));
<a name="line423"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss ZZZZ&#39;);
<a name="line424"></a>  assertEquals(&#39;02/27/2006 05:10:10 GMT-08:00&#39;, fmt.format(date, timeZone));
<a name="line425"></a>}
<a name="line426"></a>
<a name="line427"></a>function testMMddyyyyHHmmsszSimpleTimeZone() {
<a name="line428"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line429"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line430"></a>  var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
<a name="line431"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(420);
<a name="line432"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss z&#39;);
<a name="line433"></a>  assertEquals(&#39;07/27/2006 06:10:10 UTC-7&#39;, fmt.format(date, timeZone));
<a name="line434"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zz&#39;);
<a name="line435"></a>  assertEquals(&#39;07/27/2006 06:10:10 UTC-7&#39;, fmt.format(date, timeZone));
<a name="line436"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zzz&#39;);
<a name="line437"></a>  assertEquals(&#39;07/27/2006 06:10:10 UTC-7&#39;, fmt.format(date, timeZone));
<a name="line438"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zzzz&#39;);
<a name="line439"></a>  assertEquals(&#39;07/27/2006 06:10:10 UTC-7&#39;, fmt.format(date, timeZone));
<a name="line440"></a>}
<a name="line441"></a>
<a name="line442"></a>
<a name="line443"></a>function testMMddyyyyHHmmsszCommonTimeZone() {
<a name="line444"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line445"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line446"></a>  var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
<a name="line447"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(americaLosAngelesData);
<a name="line448"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss z&#39;);
<a name="line449"></a>  assertEquals(&#39;07/27/2006 06:10:10 PDT&#39;, fmt.format(date, timeZone));
<a name="line450"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zz&#39;);
<a name="line451"></a>  assertEquals(&#39;07/27/2006 06:10:10 PDT&#39;, fmt.format(date, timeZone));
<a name="line452"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zzz&#39;);
<a name="line453"></a>  assertEquals(&#39;07/27/2006 06:10:10 PDT&#39;, fmt.format(date, timeZone));
<a name="line454"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zzzz&#39;);
<a name="line455"></a>  assertEquals(&#39;07/27/2006 06:10:10 Pacific Daylight Time&#39;,
<a name="line456"></a>               fmt.format(date, timeZone));
<a name="line457"></a>  date = new Date(Date.UTC(2006, 1, 27, 13, 10, 10));
<a name="line458"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss z&#39;);
<a name="line459"></a>  assertEquals(&#39;02/27/2006 05:10:10 PST&#39;, fmt.format(date, timeZone));
<a name="line460"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zz&#39;);
<a name="line461"></a>  assertEquals(&#39;02/27/2006 05:10:10 PST&#39;, fmt.format(date, timeZone));
<a name="line462"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zzz&#39;);
<a name="line463"></a>  assertEquals(&#39;02/27/2006 05:10:10 PST&#39;, fmt.format(date, timeZone));
<a name="line464"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zzzz&#39;);
<a name="line465"></a>  assertEquals(&#39;02/27/2006 05:10:10 Pacific Standard Time&#39;,
<a name="line466"></a>      fmt.format(date, timeZone));
<a name="line467"></a>
<a name="line468"></a>  timeZone = goog.i18n.TimeZone.createTimeZone(europeBerlinData);
<a name="line469"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss z&#39;);
<a name="line470"></a>  assertEquals(&#39;02/27/2006 14:10:10 MEZ&#39;, fmt.format(date, timeZone));
<a name="line471"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss zzzz&#39;);
<a name="line472"></a>  assertEquals(&#39;02/27/2006 14:10:10 Mitteleurop\u00e4ische Zeit&#39;,
<a name="line473"></a>      fmt.format(date, timeZone));
<a name="line474"></a>}
<a name="line475"></a>
<a name="line476"></a>function testMMddyyyyHHmmssvCommonTimeZone() {
<a name="line477"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line478"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line479"></a>  var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
<a name="line480"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(americaLosAngelesData);
<a name="line481"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss v&#39;);
<a name="line482"></a>  assertEquals(&#39;07/27/2006 06:10:10 America/Los_Angeles&#39;,
<a name="line483"></a>               fmt.format(date, timeZone));
<a name="line484"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss vv&#39;);
<a name="line485"></a>  assertEquals(&#39;07/27/2006 06:10:10 America/Los_Angeles&#39;,
<a name="line486"></a>               fmt.format(date, timeZone));
<a name="line487"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss vvv&#39;);
<a name="line488"></a>  assertEquals(&#39;07/27/2006 06:10:10 America/Los_Angeles&#39;,
<a name="line489"></a>               fmt.format(date, timeZone));
<a name="line490"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss vvvv&#39;);
<a name="line491"></a>  assertEquals(&#39;07/27/2006 06:10:10 America/Los_Angeles&#39;,
<a name="line492"></a>      fmt.format(date, timeZone));
<a name="line493"></a>}
<a name="line494"></a>
<a name="line495"></a>function testMMddyyyyHHmmssvSimpleTimeZone() {
<a name="line496"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line497"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line498"></a>  var date = new Date(Date.UTC(2006, 6, 27, 13, 10, 10));
<a name="line499"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(420);
<a name="line500"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss v&#39;);
<a name="line501"></a>  assertEquals(&#39;07/27/2006 06:10:10 Etc/GMT+7&#39;, fmt.format(date, timeZone));
<a name="line502"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss vv&#39;);
<a name="line503"></a>  assertEquals(&#39;07/27/2006 06:10:10 Etc/GMT+7&#39;, fmt.format(date, timeZone));
<a name="line504"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss vvv&#39;);
<a name="line505"></a>  assertEquals(&#39;07/27/2006 06:10:10 Etc/GMT+7&#39;, fmt.format(date, timeZone));
<a name="line506"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss vvvv&#39;);
<a name="line507"></a>  assertEquals(&#39;07/27/2006 06:10:10 Etc/GMT+7&#39;, fmt.format(date, timeZone));
<a name="line508"></a>}
<a name="line509"></a>
<a name="line510"></a>
<a name="line511"></a>function test_yyyyMMddG() {
<a name="line512"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line513"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line514"></a>  var date = new Date(Date.UTC(2006, 6, 27, 20, 10, 10));
<a name="line515"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(420);
<a name="line516"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;yyyy.MM.dd G \&#39;at\&#39; HH:mm:ss vvvv&#39;);
<a name="line517"></a>  assertEquals(&#39;2006.07.27 n. Chr. at 13:10:10 Etc/GMT+7&#39;,
<a name="line518"></a>               fmt.format(date, timeZone));
<a name="line519"></a>
<a name="line520"></a>  timeZone = goog.i18n.TimeZone.createTimeZone(americaLosAngelesData);
<a name="line521"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;yyyy.MM.dd G \&#39;at\&#39; HH:mm:ss vvvv&#39;);
<a name="line522"></a>  assertEquals(&#39;2006.07.27 n. Chr. at 13:10:10 America/Los_Angeles&#39;,
<a name="line523"></a>      fmt.format(date, timeZone));
<a name="line524"></a>}
<a name="line525"></a>
<a name="line526"></a>function test_daylightTimeTransition() {
<a name="line527"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line528"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line529"></a>
<a name="line530"></a>  // US PST transition to PDT on 2006/4/2/ 2:00am, jump to 2006/4/2 3:00am,
<a name="line531"></a>  // That&#39;s UTC time 2006/4/2 10:00am
<a name="line532"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(americaLosAngelesData);
<a name="line533"></a>  var date = new Date(Date.UTC(2006, 4 - 1, 2, 9, 59, 0));
<a name="line534"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss z&#39;);
<a name="line535"></a>  assertEquals(&#39;04/02/2006 01:59:00 PST&#39;, fmt.format(date, timeZone));
<a name="line536"></a>  date = new Date(Date.UTC(2006, 4 - 1, 2, 10, 01, 0));
<a name="line537"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss z&#39;);
<a name="line538"></a>  assertEquals(&#39;04/02/2006 03:01:00 PDT&#39;, fmt.format(date, timeZone));
<a name="line539"></a>  date = new Date(Date.UTC(2006, 4 - 1, 2, 10, 00, 0));
<a name="line540"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss z&#39;);
<a name="line541"></a>  assertEquals(&#39;04/02/2006 03:00:00 PDT&#39;, fmt.format(date, timeZone));
<a name="line542"></a>}
<a name="line543"></a>
<a name="line544"></a>function test_timeDisplayOnDaylighTimeTransition() {
<a name="line545"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line546"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line547"></a>
<a name="line548"></a>  // US PST transition to PDT on 2006/4/2/ 2:00am, jump to 2006/4/2 3:00am,
<a name="line549"></a>  var date = new Date(Date.UTC(2006, 4 - 1, 2, 2, 30, 0));
<a name="line550"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(0);
<a name="line551"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss Z&#39;);
<a name="line552"></a>  assertEquals(&#39;04/02/2006 02:30:00 +0000&#39;, fmt.format(date, timeZone));
<a name="line553"></a>
<a name="line554"></a>  // US PDT transition to PST on 2006/10/29/ 2:00am, jump back to PDT
<a name="line555"></a>  // 2006/4/2 1:00am,
<a name="line556"></a>  date = new Date(Date.UTC(2006, 10 - 1, 29, 1, 30, 0));
<a name="line557"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;MM/dd/yyyy HH:mm:ss Z&#39;);
<a name="line558"></a>  assertEquals(&#39;10/29/2006 01:30:00 +0000&#39;, fmt.format(date, timeZone));
<a name="line559"></a>}
<a name="line560"></a>
<a name="line561"></a>function test_nativeDigits() {
<a name="line562"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_fa;
<a name="line563"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_fa;
<a name="line564"></a>
<a name="line565"></a>  date = new Date(2006, 6, 27, 13, 10, 10, 250);
<a name="line566"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(420);
<a name="line567"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;y/MM/dd H:mm:ss?SS&#39;);
<a name="line568"></a>  assertEquals(&#39;????/??/?? ??:??:?????&#39;, fmt.format(date));
<a name="line569"></a>
<a name="line570"></a>  // Make sure standardized timezone formats don&#39;t use native digits
<a name="line571"></a>  fmt = new goog.i18n.DateTimeFormat(&#39;Z&#39;);
<a name="line572"></a>  assertEquals(&#39;-0700&#39;, fmt.format(date, timeZone));
<a name="line573"></a>}
<a name="line574"></a>
<a name="line575"></a>// Making sure that the date-time combination is not a simple concatenation
<a name="line576"></a>function test_dateTimeConcatenation() {
<a name="line577"></a>  var date = new Date(Date.UTC(2006, 4 - 1, 2, 2, 30, 0));
<a name="line578"></a>  var timeZone = goog.i18n.TimeZone.createTimeZone(americaLosAngelesData);
<a name="line579"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line580"></a>      goog.i18n.DateTimeFormat.Format.FULL_DATETIME);
<a name="line581"></a>  // {1} &#39;at&#39; {0}
<a name="line582"></a>  assertEquals(&#39;Saturday, April 1, 2006 at 6:30:00 PM Pacific Standard Time&#39;,
<a name="line583"></a>               fmt.format(date, timeZone));
<a name="line584"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line585"></a>      goog.i18n.DateTimeFormat.Format.LONG_DATETIME);
<a name="line586"></a>  assertEquals(&#39;April 1, 2006 at 6:30:00 PM PST&#39;, fmt.format(date, timeZone));
<a name="line587"></a>  // {1}, {0}
<a name="line588"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line589"></a>      goog.i18n.DateTimeFormat.Format.MEDIUM_DATETIME);
<a name="line590"></a>  assertEquals(&#39;Apr 1, 2006, 6:30:00 PM&#39;, fmt.format(date, timeZone));
<a name="line591"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line592"></a>      goog.i18n.DateTimeFormat.Format.SHORT_DATETIME);
<a name="line593"></a>  assertEquals(&#39;4/1/06, 6:30 PM&#39;, fmt.format(date, timeZone));
<a name="line594"></a>}
<a name="line595"></a>
<a name="line596"></a>function testNotUsingGlobalSymbols() {
<a name="line597"></a>  date = new Date(2013, 10, 15);
<a name="line598"></a>
<a name="line599"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_fr;
<a name="line600"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_fr;
<a name="line601"></a>  var fmtFr = new goog.i18n.DateTimeFormat(
<a name="line602"></a>      goog.i18n.DateTimeFormat.Format.FULL_DATE);
<a name="line603"></a>
<a name="line604"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line605"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line606"></a>  var fmtDe = new goog.i18n.DateTimeFormat(
<a name="line607"></a>      goog.i18n.DateTimeFormat.Format.FULL_DATE);
<a name="line608"></a>
<a name="line609"></a>  // The two formatters should return different results (French &amp; German)
<a name="line610"></a>  assertEquals(&#39;vendredi 15 novembre 2013&#39;, fmtFr.format(date));
<a name="line611"></a>  assertEquals(&#39;Freitag, 15. November 2013&#39;, fmtDe.format(date));
<a name="line612"></a>}
<a name="line613"></a>
<a name="line614"></a>function testConstructorSymbols() {
<a name="line615"></a>  date = new Date(2013, 10, 15);
<a name="line616"></a>
<a name="line617"></a>  var fmtFr = new goog.i18n.DateTimeFormat(
<a name="line618"></a>      goog.i18n.DateTimeFormat.Format.FULL_DATE,
<a name="line619"></a>      goog.i18n.DateTimeSymbols_fr);
<a name="line620"></a>
<a name="line621"></a>  var fmtDe = new goog.i18n.DateTimeFormat(
<a name="line622"></a>      goog.i18n.DateTimeFormat.Format.FULL_DATE,
<a name="line623"></a>      goog.i18n.DateTimeSymbols_de);
<a name="line624"></a>
<a name="line625"></a>  // The two formatters should return different results (French &amp; German)
<a name="line626"></a>  assertEquals(&#39;vendredi 15 novembre 2013&#39;, fmtFr.format(date));
<a name="line627"></a>  assertEquals(&#39;Freitag, 15. November 2013&#39;, fmtDe.format(date));
<a name="line628"></a>}
<a name="line629"></a>
<a name="line630"></a>function testSupportForWeekInYear() {
<a name="line631"></a>  var date = new Date(2013, 1, 25);
<a name="line632"></a>
<a name="line633"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_fr;
<a name="line634"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_fr;
<a name="line635"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;\&#39;week\&#39; w&#39;);
<a name="line636"></a>  assertEquals(&#39;week 9&#39;, fmt.format(date));
<a name="line637"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;\&#39;week\&#39; ww&#39;);
<a name="line638"></a>  assertEquals(&#39;week 09&#39;, fmt.format(date));
<a name="line639"></a>
<a name="line640"></a>  // Make sure it uses native digits when needed
<a name="line641"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_fa;
<a name="line642"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_fa;
<a name="line643"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;\&#39;week\&#39; w&#39;);
<a name="line644"></a>  assertEquals(&#39;week ?&#39;, fmt.format(date));
<a name="line645"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;\&#39;week\&#39; ww&#39;);
<a name="line646"></a>  assertEquals(&#39;week ??&#39;, fmt.format(date));
<a name="line647"></a>}
<a name="line648"></a>
<a name="line649"></a>function testSupportForYearAndEra() {
<a name="line650"></a>  var date = new Date(2013, 1, 25);
<a name="line651"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line652"></a>      goog.i18n.DateTimePatterns.YEAR_FULL_WITH_ERA);
<a name="line653"></a>
<a name="line654"></a>  assertEquals(&#39;2013 AD&#39;, fmt.format(date));
<a name="line655"></a>
<a name="line656"></a>  date.setFullYear(213);
<a name="line657"></a>  assertEquals(&#39;213 AD&#39;, fmt.format(date));
<a name="line658"></a>
<a name="line659"></a>  date.setFullYear(11);
<a name="line660"></a>  assertEquals(&#39;11 AD&#39;, fmt.format(date));
<a name="line661"></a>
<a name="line662"></a>  date.setFullYear(-213);
<a name="line663"></a>  assertEquals(&#39;213 BC&#39;, fmt.format(date));
<a name="line664"></a>
<a name="line665"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_de;
<a name="line666"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_de;
<a name="line667"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line668"></a>      goog.i18n.DateTimePatterns.YEAR_FULL_WITH_ERA);
<a name="line669"></a>
<a name="line670"></a>  date.setFullYear(2013);
<a name="line671"></a>  assertEquals(&#39;2013 n. Chr.&#39;, fmt.format(date));
<a name="line672"></a>
<a name="line673"></a>  date.setFullYear(213);
<a name="line674"></a>  assertEquals(&#39;213 n. Chr.&#39;, fmt.format(date));
<a name="line675"></a>
<a name="line676"></a>  date.setFullYear(11);
<a name="line677"></a>  assertEquals(&#39;11 n. Chr.&#39;, fmt.format(date));
<a name="line678"></a>
<a name="line679"></a>  date.setFullYear(-213);
<a name="line680"></a>  assertEquals(&#39;213 v. Chr.&#39;, fmt.format(date));
<a name="line681"></a>
<a name="line682"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_ja;
<a name="line683"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_ja;
<a name="line684"></a>  fmt = new goog.i18n.DateTimeFormat(
<a name="line685"></a>      goog.i18n.DateTimePatterns.YEAR_FULL_WITH_ERA);
<a name="line686"></a>
<a name="line687"></a>  date.setFullYear(2013);
<a name="line688"></a>  assertEquals(&#39;??2013?&#39;, fmt.format(date));
<a name="line689"></a>
<a name="line690"></a>  date.setFullYear(213);
<a name="line691"></a>  assertEquals(&#39;??213?&#39;, fmt.format(date));
<a name="line692"></a>
<a name="line693"></a>  date.setFullYear(11);
<a name="line694"></a>  assertEquals(&#39;??11?&#39;, fmt.format(date));
<a name="line695"></a>
<a name="line696"></a>  date.setFullYear(-213);
<a name="line697"></a>  assertEquals(&#39;???213?&#39;, fmt.format(date));
<a name="line698"></a>}
<a name="line699"></a>
<a name="line700"></a>// Creates a string by concatenating the week number for 7 successive days
<a name="line701"></a>function weekInYearFor7Days() {
<a name="line702"></a>  var date = new Date(2013, 0, 1); // January
<a name="line703"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;w&#39;);
<a name="line704"></a>  var result = &#39;&#39;;
<a name="line705"></a>  for (var i = 1; i &lt;= 7; ++i) {
<a name="line706"></a>    date.setDate(i);
<a name="line707"></a>    result += fmt.format(date);
<a name="line708"></a>  }
<a name="line709"></a>  return result;
<a name="line710"></a>}
<a name="line711"></a>
<a name="line712"></a>// Expected results from ICU4J v51. One entry will change in v52.
<a name="line713"></a>// These cover all combinations of FIRSTDAYOFWEEK / FIRSTWEEKCUTOFFDAY in use.
<a name="line714"></a>function testWeekInYearI18n() {
<a name="line715"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_bn_BD;
<a name="line716"></a>  assertEquals(&#39;bn_BD&#39;, &#39;???????&#39;, weekInYearFor7Days());
<a name="line717"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_en_IE;
<a name="line718"></a>  assertEquals(&#39;en_IE&#39;, &#39;1111122&#39;, weekInYearFor7Days());
<a name="line719"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_fr_DJ;
<a name="line720"></a>  assertEquals(&#39;fr_DJ&#39;, &#39;1111222&#39;, weekInYearFor7Days());
<a name="line721"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_he_IL;
<a name="line722"></a>  assertEquals(&#39;he_IL&#39;, &#39;1111122&#39;, weekInYearFor7Days());
<a name="line723"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_ar_SA;
<a name="line724"></a>  assertEquals(&#39;ar_SA&#39;, &#39;???????&#39;, weekInYearFor7Days());
<a name="line725"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_ar_AE;
<a name="line726"></a>  assertEquals(&#39;ar_AE&#39;, &#39;???????&#39;, weekInYearFor7Days());
<a name="line727"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_en_IN;
<a name="line728"></a>  assertEquals(&#39;en_IN&#39;, &#39;1111122&#39;, weekInYearFor7Days());
<a name="line729"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_en_GB;
<a name="line730"></a>  assertEquals(&#39;en_GB&#39;, &#39;1111112&#39;, weekInYearFor7Days());
<a name="line731"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_en_US;
<a name="line732"></a>  assertEquals(&#39;en_US&#39;, &#39;1111122&#39;, weekInYearFor7Days());
<a name="line733"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_ro_RO;
<a name="line734"></a>  assertEquals(&#39;ro_RO&#39;, &#39;1111112&#39;, weekInYearFor7Days());
<a name="line735"></a>}
<a name="line736"></a>
<a name="line737"></a>// Regression for b/11567443 (no method &#39;getHours&#39; when formatting a
<a name="line738"></a>// goog.date.Date)
<a name="line739"></a>function test_variousDateTypes() {
<a name="line740"></a>  goog.i18n.DateTimePatterns = goog.i18n.DateTimePatterns_fr;
<a name="line741"></a>  goog.i18n.DateTimeSymbols = goog.i18n.DateTimeSymbols_fr;
<a name="line742"></a>
<a name="line743"></a>  var fmt = new goog.i18n.DateTimeFormat(
<a name="line744"></a>      goog.i18n.DateTimeFormat.Format.MEDIUM_DATETIME);
<a name="line745"></a>
<a name="line746"></a>  var date = new Date(2006, 6, 27, 13, 10, 42, 250);
<a name="line747"></a>  assertEquals(&#39;27 juil. 2006 13:10:42&#39;, fmt.format(date));
<a name="line748"></a>
<a name="line749"></a>  var gdatetime = new goog.date.DateTime(2006, 6, 27, 13, 10, 42, 250);
<a name="line750"></a>  assertEquals(&#39;27 juil. 2006 13:10:42&#39;, fmt.format(gdatetime));
<a name="line751"></a>
<a name="line752"></a>  var gdate = new goog.date.Date(2006, 6, 27);
<a name="line753"></a>  var fmtDate =
<a name="line754"></a>      new goog.i18n.DateTimeFormat(goog.i18n.DateTimeFormat.Format.MEDIUM_DATE);
<a name="line755"></a>  assertEquals(&#39;27 juil. 2006&#39;, fmtDate.format(gdatetime));
<a name="line756"></a>  try {
<a name="line757"></a>    fmt.format(gdate);
<a name="line758"></a>    fail(&#39;Should have thrown exception.&#39;);
<a name="line759"></a>  } catch (e) {}
<a name="line760"></a>}
<a name="line761"></a>
<a name="line762"></a>function testExceptionWhenFormattingNull() {
<a name="line763"></a>  var fmt = new goog.i18n.DateTimeFormat(&#39;M/d/y&#39;);
<a name="line764"></a>  try {
<a name="line765"></a>    fmt.format(null);
<a name="line766"></a>    fail(&#39;Should have thrown exception.&#39;);
<a name="line767"></a>  } catch (e) {}
<a name="line768"></a>}
</pre>


</body>
</html>
